
package cs425proj.model;

import java.sql.*;

/**
 *
 * @author prateekpatil ,rakesh ,Rahul
 */
public class querryDB {  
       private Connection con ;
       private ResultSet rs1 ;
    public ResultSet doQuerry(String input){
        
       String connStr ="jdbc:oracle:thin:@fourier.cs.iit.edu:1521:orcl";
       
       Statement stm;
       String inputCraft= input;
       String output ="";
           try{
               //load the drives
            Class.forName("oracle.jdbc.driver.OracleDriver");

            //initialize the connection variable
               con = DriverManager.getConnection(connStr, "rvedere", "Iitfeb12");
            stm = con.createStatement();
            //Sql Querry 
            String qrry1 = "select c.title as cType,sum(e.cost) as Rev from class1 c,enrollment e where e.class_id = c.id and c.type='"+inputCraft+"' group by c.title";
            //System.out.println(qrry1);
            rs1= stm.executeQuery(qrry1);
                      
             }catch(SQLException e){e.printStackTrace();}
              catch(ClassNotFoundException cn){cn.printStackTrace();}
           return rs1;
           }
    
    public void closeConnection(){
           try{
            con.commit();
            con.close();
    
           }catch(SQLException e){e.printStackTrace();}
    }
}
